package com.woniu.info.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class MessageRabbitDirectConfig {

    // 创建交换机
    @Bean
    public Exchange messageExchange(){
        return new DirectExchange("message_exchange",true,false,null);
    }
    // 创建队列
    @Bean
    public Queue queueMessageShop(){
        return new Queue("message_shop_queue",true,false,false,null);
    }

    @Bean
    public Queue queueMessageUser(){
        return new Queue("message_user_queue",true,false,false,null);
    }
    // 绑定关系
    @Bean
    public Binding bindingMessageShop(@Qualifier("queueMessageShop") Queue queue , Exchange messageExchange){
        return BindingBuilder.bind(queue).to(messageExchange).with("add_message_shop").noargs();
    }

    @Bean
    public Binding bindingMessageUser(@Qualifier("queueMessageUser") Queue queue , Exchange messageExchange){
        return BindingBuilder.bind(queue).to(messageExchange).with("add_message_user").noargs();
    }

}
